export default {
  data() {
    return {
      list: {},
      carList: {},
      histore: [],
      pageSize: 30,
      // title: '查看更多',
      isMore: false,
    }
  },
  created() {
    this.getStoreCustomerData()
  },
  onLoad(op) {
    let list = JSON.parse(op.list)
    this.list = list
    console.log(this.list, '11')
  },
  computed: {
    showList() {
      if (this.isMore === false) { //当数据不需要完全显示的时候
        var showList = [] //定义一个空数组
        if (this.histore.length > 3) { //这里我们先显示前三个
          for (var i = 0; i < 3; i++) {
            showList.push(this.histore[i])
          }
        } else {
          showList = this.histore
        }
        return showList //返回当前数组
      } else {
        return this.histore
      }
    },
    title() {
      if (this.isMore === false) { //对文字进行处理
        return '点击展开'
      } else {
        return '点击收起'
      }
    }
  },
  methods: {
    onMore() {
      this.isMore = false
      this.histore = []
      this.pageSize = 30
      this.getStoreCustomerData()
    },
    onSq() {
      this.isMore = true
      this.histore = []
      this.pageSize = 3
      this.getStoreCustomerData()
    },
    returnTime(time) {
      if (time) {
        return time.split('T')[0]
      }
    },
    async getStoreCustomerData() {
      uni.showLoading({
        title: '加载中',
        mask: true
      })
      let storeId = uni.getStorageSync('userInfoDetail').store.storeId
      try {
        let data = {
          'pageIndex': 3,
          'pageSize': this.pageSize,
          'uid': this.list.uid,
          'store_Id': storeId
        }
        const res = await this.$api.banner.getStoreCustomerData(data)
        uni.hideLoading()
        //   if (res.data.list[0].list.length <= 3){
        // this.title = '没有更多'
        //   }
        this.histore = res.data.list[0].list
        this.carList = res.data.list[0].carList[0]
      } catch (e) {
        uni.hideLoading()
      }
    },
    goPage() {
      uni.navigateTo({
        url: '/pages_afterSales/deliveryCarReport/deliveryCarReport?id=' + this.list.uid
      })
    }
  }
}
